package com.facebook.commands.query 
{
	import com.facebook.commands.FacebookCall;
	import com.facebook.utils.FacebookPostUtils;
	import com.facebook.utils.SQL;

	import flash.events.Event;

	/**
	 * @author Ben Smith
	 */
	public class Query extends FacebookCall 
	{

		static public const METHOD : String = "fql.query"
		static public const FUNCTION_CALL:String="FB.api"
		
		
		
		private var fields:Vector.<String>;
		private var table:String;
		private var condition:String;
	
		
		private var _select:String
		
		

		public function Query(sql:SQL)
		{
			method = Query.METHOD;
			_select=sql.toString()

		}

		override public function toString() :String
		{
			return Query.METHOD
		}
		
		
		override public function makeCall(format:String="JSON"):FacebookCall{
			super.makeCall(format)
			FacebookPostUtils.registerCall(this);
		
		/*trace(_select)	
			//https://api.facebook.com/method/fql.query?query=SELECT%20name%20FROM%20profile%20WHERE%20id=1435915624		
			_jsCall=FUNCTION_CALL+'({format:\''+format +'\',method:\''+METHOD+'\',query:\"'+ _select + "\"},"+FacebookConnectUtils.createAnonymousCallFunction(); 
			FacebookConnectUtils.registerCall(this);
			trace(_jsCall)
			ExternalInterface.call(_jsCall);
		*/	
			return this
		}

		private function onCOMPLETEION(event : Event) : void 
		{
			trace(event,event.target.data)
		}

		override public function quickTrace():void{
			
			
		
				_parser.quickTrace(result.result)
				
		
			
		}
		
		
	
	}
}
